package com.waitingresult;


import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.json.JSONUtil;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * @Author: WangShuai
 * @CreateTime: 2024/02/28  15:01
 * @Description:
 * @Version: 1.0
 */
public class StringTest {


    public static void main(String[] args) {
        String json = """
                [
                   {
                        "customerId": 3756328590,
                        "convertId": 891056376,
                        "currency": "EUR",
                        "siteCode": "DE"
                    },
                    {
                        "customerId": 8575241033,
                        "convertId": 891004075,
                        "currency": "CAD",
                        "siteCode": "CA"
                    },
                    {
                        "customerId": 6873347092,
                        "convertId": 891006847,
                        "currency": "USD",
                        "siteCode": "US"
                    },
                    {
                        "customerId": 7385281211,
                        "convertId": 890103809,
                        "currency": "EUR",
                        "siteCode": "FR"
                    },
                    {
                        "customerId": 2039137909,
                        "convertId": 891005971,
                        "currency": "EUR",
                        "siteCode": "IT"
                    },
                   {
                        "customerId": 8949051845,
                        "convertId": 890102534,
                        "currency": "EUR",
                        "siteCode": "ES"
                    },
                   {
                        "customerId": 4071957088,
                        "convertId": 890104796,
                        "currency": "GBP",
                        "siteCode": "UK"
                    },
                   {
                        "customerId": 4820258639,
                        "convertId": 890100374,
                        "currency": "EUR",
                        "siteCode": "EU"
                    },
                    {
                        "customerId": 2362018984,
                        "convertId": 891056346,
                        "currency": "AUD",
                        "siteCode": "AU"
                    },
                    {
                        "customerId": 2265773048,
                        "convertId": 891006679,
                        "currency": "EUR",
                        "siteCode": "NL"
                    },
                    {
                        "customerId": 4882409954,
                        "convertId": 1007965105,
                        "currency": "MXN",
                        "siteCode": "MX"
                    },
                    {
                        "customerId": 5560916999,
                        "convertId": 1007134784,
                        "currency": "JPY",
                        "siteCode": "JP"
                    },
                    {
                        "customerId": 4105310860,
                        "convertId": 1007966806,
                        "currency": "PLN",
                        "siteCode": "PL"
                    },
                   {
                        "customerId": 6806233266,
                        "currency": "THB",
                        "siteCode": "TH"
                    },
                    {
                        "customerId": 6156684549,
                        "currency": "IDR",
                        "siteCode": "ID"
                    },
                    {
                        "customerId": 5817064584,
                        "currency": "PHP",
                        "siteCode": "PH"
                    },
                    {
                        "customerId": 6873347092,
                        "currency": "RUB",
                        "siteCode": "RU"
                    },
                    {
                        "customerId": 6873347092,
                        "currency": "BRL",
                        "siteCode": "BR"
                    },
                    {
                        "customerId": 6873347092,
                        "currency": "CLP",
                        "siteCode": "CL"
                    },
                    {
                        "customerId": 6873347092,
                        "currency": "MYR",
                        "siteCode": "MY"
                    },
                    {
                        "customerId": 6873347092,
                        "currency": "EUR",
                        "siteCode": "PT"
                    },
                    {
                        "customerId": 6873347092,
                        "currency": "EUR",
                        "siteCode": "SE"
                    }
                ]
                """;
        List<SiteConverterConfigEntity> siteConverterConfigList = JSONUtil.toList(json, SiteConverterConfigEntity.class);
        System.err.println(siteConverterConfigList);
    }
    @Data
    static class SiteConverterConfigEntity{
        private long customerId;
        private long convertId;
        private String currency;
        private String siteCode;
    }

    public static String test(long completedTime, long timeOffset) {
        completedTime = completedTime - timeOffset * 60;
        LocalDateTime localDateTime = LocalDateTimeUtil.of(completedTime);
        String type = timeOffset > 0 ? "-" : "+";
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        return localDateTime.format(formatter) + type + String.format("%02d:00", Math.abs(timeOffset) / 60);
    }


}
